﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TWiStEr.Math;
using Phys.Model.Affectors;

namespace Phys.Model {
	public class CompositeObject : AObject {
		public CompositeObject() {
			Objects = new List<IObject>();
		}
		public override double Mass { get { return Objects.Sum(o => o.Mass); } set { } }
		public IList<IObject> Objects { get; protected set; }
		public IEnumerable<IObject> AllPrimitives {
			get { return Objects.SelectMany(o => o is CompositeObject ? ((CompositeObject)o).AllPrimitives : new[] { o }); }
		}
		public IEnumerable<IObject> AllObjects {
			get { return Objects.SelectMany(o => (o is CompositeObject ? ((CompositeObject)o).AllPrimitives : Enumerable.Empty<IObject>()).Concat(new[] { o })); }
		}
	}
}
